<template>
  <div>
    <el-descriptions class="margin-top" title="" :column="3" size="medium" border>
      <el-descriptions-item>
        <template slot="label">
          案件編號
        </template>
        {{ caseInfo.itemNo }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          案件名稱
        </template>
        {{ caseInfo.name }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          狀態
        </template>
        {{ caseInfo.state == 0 ? '進行中' : '已完成' }}
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          創建時間
        </template>
        {{ createTime }}
      </el-descriptions-item>
    </el-descriptions>
  </div>

</template>

<script>
import { timestampToTime } from '@/utils/tools'

export default {
  name: 'case-detail',

  data() {
    return {
      caseList: [],
      ruleForm: {
        userId: ''
      },
      loading: false,
      caseInfo: {
        createTime: '',
        groupId: '',
        id: '',
        itemNo: '',
        lawPwd: '',
        name: '',
        privateKey: '',
        publicKey: '',
        state: '',
        userId: '',
      }
    }
  },

  computed: {
    itemNo: function() {
      return this.$route.params.itemNo
    },

    createTime: function() {
      console.log(this.caseInfo)
      return timestampToTime(this.caseInfo.createTime)
    }
  },

  mounted() {
    this.$store.dispatch('netdisk/fetchLawCaseInfo', { itemNo: this.itemNo }).then(res => {
      console.log('获取案件详情')
      console.log(res)
      this.loading = false
      this.$message.success(res.message)
      this.caseInfo = { ...this.caseInfo, ...res.result.gpsLawCaseInfo }
    }).catch(err => {
      console.error(err)
      this.loading = false
      this.$message.error(err)
      return false
    })
  },
}
</script>

<style scoped lang="scss">
@import "../../assets/css/them.scss";

/deep/ .el-descriptions .is-bordered {
  table-layout: fixed !important;
}
</style>
